Usage:

perl FFVI_C2FF6D.pl -m <mode> [-g|-hi|-ho] -
perl FFVI_C2FF6D.pl -m <mode> [-g|-hi|-ho|-n|-s <start address>] <file>

Implements the decompression routine (a variant on LZ77 using a 0x800 byte sliding window, distinguishing length-distance pairs from literals by prefixing every group of 8 pairs/literals with a single byte, each bit of which controls whether the next corresponding byte is a literal or a length-distance pair; length-distance pairs are encoded as 2 bytes [abcdefgh ijklmnop] where length is [lmnop] and distance is [ijkabcdefgh]) found at 0xC2FF6D in at least the original Japanese and both English releases of Final Fantasy VI on the SNES.
Also implements a complementary compression routine to generate data that the aforementioned decompression routine will be able to decompress.

Options:

-g: instead of normal output, display and group data copied from buffer (mainly useful for debugging; try it if you're curious)
-hi: instead of raw binary, assume input is hex-encoded data
-ho: instead of raw binary, output hex-encoded data
-m <mode>: use 'c' for compression or 'd' for decompression
-n: when writing compression results to <file>, always overwrite the entire <file> instead of updating a portion of an existing file
-s <start address>: address to start reading from/writing to in <file> (defaults to 0, accepts both decimal and hexadecimal numbers [when prefixed with '0x'], ignored for compression to STDOUT)
<file>: name of file to read from/write to; use '-' if you want <file> to be STDIN or STDOUT

Decompression works from <file> to STDOUT, compression works from STDIN to <file>. Note that compression output *overwrites* whatever part of <file> you tell it to, so you should probably make backups and test it with STDOUT before doing anything dangerous - nobody wants you to accidentally destroy any of your hard work!

Some examples:
- decompress data from ROM starting from 0x2686C:
perl FFVI_C2FF6D.pl -m d -s 0x2686C "Final Fantasy III (U) (V1.0) [!].smc"
- same thing but using decimal start address:
perl FFVI_C2FF6D.pl -m d -s 157804 "Final Fantasy III (U) (V1.0) [!].smc"

- same thing but with hex-encoded output:
perl FFVI_C2FF6D.pl -m d -ho -s 0x2686C "Final Fantasy III (U) (V1.0) [!].smc"

- decompress hex-encoded file compressed.txt, writing hex-encoded data to STDOUT
perl FFVI_C2FF6D.pl -m d -hi -ho compressed.txt
- same thing
perl FFVI_C2FF6D.pl -m d -hi -ho - < compressed.txt

- compress data from file decompressed.bin, writing to ROM at 0x2686C:
perl FFVI_C2FF6D.pl -m c -s 0x2686C "Final Fantasy III (U) (V1.0) [!].smc" < decompressed.bin

- compress hex-encoded data from file decompressed.txt, writing to ROM at 0x2686C:
perl FFVI_C2FF6D.pl -m c -hi -s 0x2686C "Final Fantasy III (U) (V1.0) [!].smc" < decompressed.txt

- same thing, but as a filter
cat decompressed.txt | perl FFVI_C2FF6D.pl -m c -hi -s 0x2686C "Final Fantasy III (U) (V1.0) [!].smc"

- speaking of filters, assuming data has already been optimally compressed, this should be a super-expensive nop:
perl FFVI_C2FF6D.pl -m d -s 0x2686C "Final Fantasy III (U) (V1.0) [!].smc" | perl FFVI_C2FF6D.pl -m c -s 0x2686C "Final Fantasy III (U) (V1.0) [!].smc"